import type {
  HospitalItem,
  ReqAddHospitalSetParams,
  ReqHospitalSetParams,
  ReqHospitalSetResponse,
  ReqUpdateHospitalSetParams,
} from "./model/hospitalSetTypes";
import { request } from "@utils/http";
import type { Key } from "react";
//下面的导入也可以
// import request from '@utils/http/request'

/**
 * 声明一个函数, 发送请求, 获取医院设置信息
 * @param param 请求的参数 object
 * @returns Promise<ReqHospitalSetResponse>  返回的 promise 成功的结果值类型为 ReqHospitalSetResponse
 */
export function reqGetHospitalSet({
  page,
  limit,
  hosname,
  hoscode,
}: ReqHospitalSetParams) {
  return request.get<any, ReqHospitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
    params: {
      hosname,
      hoscode,
    },
  }); // /dev-api/admin/hosp/hospitalSet/1/2
}

/**
 * 新增医院设置
 * @param hospitalSet 医院设置的信息
 * @returns Promise<null>
 */
export function reqAddHospitalSet(hospitalSet: ReqAddHospitalSetParams){
  return request.post('/admin/hosp/hospitalSet/save', hospitalSet)
}

/**
 * 通过 id 获取医院设置的信息
 * @param id 医院信息的 id
 * @returns  Promise<HospitalItem>
 */
export function reqGetHospitalSetById(id: string){
  return request.get<any, HospitalItem>(`/admin/hosp/hospitalSet/get/${id}`);
}

/**
 * 更新医院设置信息
 * @param hospitalSet 更新医院设置信息对象
 * @returns Promise<null>
 */
export function reqUpdateHospitalSet(hospitalSet: ReqUpdateHospitalSetParams){
  return request.put<any, null>('/admin/hosp/hospitalSet/update', hospitalSet) // put post patch  (url, data);
}
/**
 * 根据 id 删除对应医院设置信息
 * @param id 医院设置的 id
 * @returns Promise<null>
 */
export function reqRemoveHospitalSet(id: string){
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

/**
 * 通过 id 列表删除医院设置信息
 * @param idList ID 列表
 * @returns  Promise<null>
 */
export function reqBatchRemoveHospitalSet(idList: Key[]){
  // get 和 delete 请求如何设置请求体
  return request.delete<any, null>('/admin/hosp/hospitalSet/batchRemove', {
    data: idList
  });
}